const { BrowserWindow, app, ipcMain, screen } = require("electron");
const path = require("path");
// const { createMenu } = require("./menu.cjs");
const { dialogMenu } = require("./dialogMenu.cjs");
const { createWin } = require("./window.cjs");
require("./contextmenu.cjs");
require("./ipcmain.cjs");

app.whenReady().then(() => {
  const win = createWin();
  // createMenu(win);
  dialogMenu(win);
  // 兼容mac; 即使没有打开任何窗口，macOS 应用通常也会继续运行。 在没有窗口可用时调用 app 会打开一个新窗口。
  app.on("activate", () => {
    if (BrowserWindow.getAllWindows().length === 0) {
      const win = createWin();
      //  createMenu(win);
      dialogMenu(win);
    }
  });
});

ipcMain.on("sendToMain", (event, args) => {
  console.log("sendToMain");
  console.log("main", process.versions);
  event.reply("sendToRenderer", process.versions);
});
